<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>HelloWorld</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>Instance Methods</h1>
    <hr>
    <div id="app"></div>

    <p><button onclick="destroy()">卸载</button></p>
    <p><button onclick="reload()">reload</button></p>
    <p><button onclick="tick()">next tick</button></p>

   
    <script type="text/javascript">

    Vue.config.productionTip = false

        var jspang = Vue.extend({

            template : `<p> {{message}}</p>`,

            //这里直接写message是不行的,需要Return
            data:function(){
                return {
                    message : 'Hello , I am JSPang!'
                }
            },
            mounted:function(){
                console.log("mounted 被创建!")
            },
            destroyed:function(){
                console.log("destroy 销毁之后!")
            },
            updated:function(){
                console.log("updated 更新之后!")
            }
        })

        //挂载
        var vm = new jspang().$mount("#app");

        function destroy(){
            vm.$destroy();
        }

        function reload(){
            vm.$forceUpdate();
        }

        function tick(){
            vm.message="update message info ";
            vm.$nextTick(function(){
                console.log('message更新完后我被调用了');
            })
        }

    </script>
</body>
</html>